// import lodash from 'lodash';
import { allSysName, allRoleName } from '../services/manage-by-query-controller';

export default {
  namespace: 'GlobalEnumModel',

  state: {
    sysNameList: [],  // 所有的系统名称
    roleNameList: [], // 所有的角色名称
  },

  effects: {
    *allSysName(_, { call, put }) {
      // 请求数据
      const sysNameList = yield call(allSysName);
      if (!sysNameList) return;
      yield put({ type: 'save', payload: { sysNameList } });
    },
    *allRoleName(_, { call, put }) {
      // 请求数据
      const roleNameList = yield call(allRoleName);
      if (!roleNameList) return;
      yield put({ type: 'save', payload: { roleNameList } });
    },
  },

  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
  },
};
